package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author: 汪腾伟
 * @date: 2020/7/31
 * @desrcption: 回款计划提醒类型枚举码
 * @version:1.0
 */
@Getter
public enum PaymentTaskNotifyTypeEnum {
    // 回款计划提醒类型
    NO_NOTIFY(0,"noNotify", "enum.paymentTaskNotifyType.alias.no_notify"),


    ADVANCE_ONE_QUARTER_HOUR(1,"advanceOneQuarterHour", "enum.paymentTaskNotifyType.alias.advance_one_quarter_hour"),


    ADVANCE_ONE_HOUR(2,"advanceOneHour", "enum.paymentTaskNotifyType.alias.advance_one_hour"),


    ADVANCE_ONE_DAY(3,"advanceOneDay", "enum.paymentTaskNotifyType.alias.advance_one_day"),


    ADVANCE_THREE_DAY(4,"advanceThreeDay", "enum.paymentTaskNotifyType.alias.advance_three_day"),


    ADVANCE_ONE_WEEK(5,"advanceOneWeek", "enum.paymentTaskNotifyType.alias.advance_one_week"),


    CUSTOM_TIME(6,"customTime", "enum.paymentTaskNotifyType.alias.custom_time"),


    UNKNOW(404,"unkonw", "enum.paymentTaskNotifyType.alias.unknow"),
    ;
    private Integer code;
    private String attr;
    private String alias;

    PaymentTaskNotifyTypeEnum(Integer code, String attr, String alias) {
        this.code = code;
        this.attr = attr;
        this.alias = alias;
    }

    public static PaymentTaskNotifyTypeEnum getByCode(Integer code){
        for (PaymentTaskNotifyTypeEnum paymentTaskNotifyTypeEnum : values()){
            if (Objects.equals(paymentTaskNotifyTypeEnum.code,code)){
                return paymentTaskNotifyTypeEnum;
            }
        }
        return UNKNOW;
    }

    public String getAlias() {
        return I18nMessageUtil.getMessage(alias);
    }
}
